import * as api from '../../service/api'

const state = {
	orderlist : {},
	noUsedOrderList : [],
}

const getters = {
	orderlist : state => state.orderlist,
	noUsedOrderList : state => state.noUsedOrderList,
}

const actions = {
	
	async getOrderList ({ commit }, para) {
		let res = await api.orderList(
			para.pageNo,
			para.pageSize,
			para.start_time,
			para.end_time,
			para.group,
			para.title,
			para.code,
			para.mobile,
			para.name,
			para.ticket_state,
			para.usedstate,
			para.order_unique_code,
		);
		console.log(res);

		if(res.errcode === 0){
			commit('setOrderList', res.data);
			para.cb(res.data);
		}
	},


	async noUsedOrderList ({ commit }, para) {
		let res = await api.noUsedOrderList();
        console.log('未使用订单列表');
        console.log(res);
        if(res.errcode == 0){
            commit('setNoUsedOrderList', res.data);
        }
	},
}

const mutations = {
	setOrderList (state, obj) {
		state.orderlist = obj;
	},
	setNoUsedOrderList (state, obj) {
		state.noUsedOrderList = obj;
	}
}

export default {
  state,
  getters,
  actions,
  mutations
}
